package org.grizz;

import org.apache.log4j.Logger;
import org.grizz.game.TestService;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input.Keys;
import com.badlogic.gdx.InputAdapter;
import com.badlogic.gdx.InputMultiplexer;
import com.badlogic.gdx.InputProcessor;

@Configuration
public class AppConfiguration {
	public AppConfiguration() {
		Logger log = Logger.getLogger(AppConfiguration.class);
		log.info("AppConfiguration object is created!");
	}
	
	//Remember that GDX classes need to be defined as LAZY beans!
	
	@Bean
	public TestService testService() {
		return new TestService();
	}
	
	@Bean
	public InputProcessor inputProcessor() {
		InputMultiplexer inputMultiplexer = new InputMultiplexer();
		
		inputMultiplexer.addProcessor(new InputAdapter() {
			public boolean keyDown(int keycode) {
				if(Keys.ESCAPE == keycode) {
					Gdx.app.exit();
					return true;
				}
				return false;
			};
		});
		
		return inputMultiplexer;
	}
}
